/*    */ package com.newcrm.webapi.sub;
/*    */ 
/*    */ import com.newcrm.bean.CompanyInfo;
/*    */ import com.newcrm.bean.User;
/*    */ import com.newcrm.db.TagManager;
/*    */ import com.newcrm.exception.DBException;
/*    */ import com.newcrm.util.Util;
/*    */ import com.newcrm.webapi.AbstractAction;
/*    */ import com.newcrm.webapi.AbstractHttpServlet;
/*    */ import java.io.IOException;
/*    */ import java.io.PrintWriter;
/*    */ import javax.servlet.ServletException;
/*    */ import javax.servlet.http.HttpServletRequest;
/*    */ import javax.servlet.http.HttpServletResponse;
/*    */ import net.sf.json.JSONObject;
/*    */ import org.apache.log4j.Logger;
/*    */ 
/*    */ public class DeleteTag extends AbstractAction
/*    */ {
/* 23 */   private static Logger logger = Logger.getLogger(DeleteTag.class.getName());
/*    */ 
/* 25 */   private int id = 0;
/*    */ 
/*    */   public DeleteTag(AbstractHttpServlet servlet) {
/* 28 */     super(servlet);
/*    */   }
/*    */ 
/*    */   public DeleteTag(AbstractHttpServlet servlet, String id) {
/* 32 */     super(servlet);
/* 33 */     this.id = Util.str2Int(id);
/*    */   }
/*    */ 
/*    */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*    */     throws IOException, ServletException
/*    */   {
/* 39 */     TagManager manager = new TagManager();
/* 40 */     int companyId = super.getLoginUser(request).companyId;
/*    */     try {
/* 42 */       int result = manager.delete(this.id);
/* 43 */       JSONObject jsonObject = new JSONObject();
/* 44 */       if (result <= 0) {
/* 45 */         jsonObject.put("error", "1");
/*    */       } else {
/* 47 */         jsonObject.put("error", "0");
/*    */ 
/* 49 */         CompanyInfo company = super.getCompany(companyId);
/*    */         try
/*    */         {
/* 52 */           company.tags = manager.list(companyId);
/*    */         } catch (DBException e) {
/* 54 */           logger.warn("get all tags failed", e);
/*    */         }
/*    */       }
/* 57 */       response.setContentType("text/html;charset=utf-8");
/* 58 */       PrintWriter out = response.getWriter();
/* 59 */       jsonObject.put("result", Integer.valueOf(result));
/* 60 */       out.println(jsonObject);
/* 61 */       out.flush();
/* 62 */       out.close();
/*    */     } catch (DBException e) {
/* 64 */       e.printStackTrace();
/*    */     }
/*    */   }
/*    */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.DeleteTag
 * JD-Core Version:    0.6.1
 */